package mh.demo.restful.exception;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
public class ApiExceptionHandler {

    @ExceptionHandler(UserNotFoundException.class)
    public ResponseEntity<ErrorResponse>handleUserNotFound(UserNotFoundException ex){
        ErrorResponse errRes = new ErrorResponse("0", ex.getMessage());
        return ResponseEntity.status(HttpStatus.NOT_FOUND).body(errRes);
    }

}


